package com.snsoft.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.MapListHandler;

import com.snsoft.util.JdbcUtils;

public class ManageDao {

	/**
	 * 获取负责人列表
	 * 
	 * @return
	 * @throws SQLException
	 */
	public List<Map<String, Object>> getPrincipals() throws SQLException {
		QueryRunner runner = new QueryRunner(JdbcUtils.getDataSource());
		String sql = "SELECT userID, userName FROM users WHERE role=2 AND deleteFlag=1;";
		return runner.query(sql, new MapListHandler());
	}

	/**
	 * 设置下载权限
	 * 
	 * @param userID
	 * @param download
	 * @return
	 * @throws SQLException
	 */
	public int setDownload(String userID, String download) throws SQLException {
		QueryRunner runner = new QueryRunner(JdbcUtils.getDataSource());
		String sql = "UPDATE users SET downLoad=? WHERE userID=?;";
		return runner.update(sql, new Object[] { download, userID });
	}

}
